package com.tqjc.system.system.wrapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tqjc.system.common.Wrapper.BaseWrapper;
import com.tqjc.system.common.enums.AlarmStatusEnum;
import com.tqjc.system.system.entity.SysAlarmInfoEntity;
import org.apache.commons.collections4.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @Author: 86195
 * @Date: 2024/1/4 10:47
 **/
public class AlarmInfoWrapper extends BaseWrapper<SysAlarmInfoEntity> {


    public AlarmInfoWrapper(IPage<SysAlarmInfoEntity> pageResult) {
        super(pageResult);
        List<SysAlarmInfoEntity> records = pageResult.getRecords();
        if(CollectionUtils.isNotEmpty(records)){
            List<SysAlarmInfoEntity> list = new ArrayList<>(records.size());

            records.forEach( e ->{
                e.setStatus(AlarmStatusEnum.getDescByStatus(e.getStatus()));
                list.add(e);
            });
            pageResult.setRecords(list);
        }
    }


    public AlarmInfoWrapper(List<SysAlarmInfoEntity> lstResult) {
        super(lstResult);
    }
}
